import pandas as pd
import matplotlib.pyplot as plt
import re

# 日志数据
log_data = """
[INFO] [1743665303.100914, 321.005000]: Goal sent at time: 1743665303.1007185
[INFO] [1743665303.105654, 321.010000]: Robot started moving. Planning time: 0.0048 seconds
[INFO] [1743665303.107620, 321.012000]: Distance to goal: 0.7604 meters
[INFO] [1743665306.851128, 324.744000]: Goal sent at time: 1743665306.8508863
[INFO] [1743665306.857098, 324.750000]: Robot started moving. Planning time: 0.0059 seconds
[INFO] [1743665306.859630, 324.752000]: Distance to goal: 3.7996 meters
[INFO] [1743665308.446995, 326.336000]: Goal sent at time: 1743665308.4467678
[INFO] [1743665308.451171, 326.340000]: Robot started moving. Planning time: 0.0042 seconds
[INFO] [1743665308.453117, 326.342000]: Distance to goal: 5.1498 meters
[INFO] [1743665310.025213, 327.909000]: Goal sent at time: 1743665310.0244126
[INFO] [1743665310.026533, 327.910000]: Robot started moving. Planning time: 0.0018 seconds
[INFO] [1743665310.030139, 327.916000]: Distance to goal: 4.7402 meters
[INFO] [1743665311.938220, 329.819000]: Goal sent at time: 1743665311.9379528
[INFO] [1743665311.939206, 329.820000]: Robot started moving. Planning time: 0.0010 seconds
[INFO] [1743665311.941628, 329.822000]: Distance to goal: 2.8509 meters
[INFO] [1743665313.667838, 331.545000]: Goal sent at time: 1743665313.6677034
[INFO] [1743665313.672952, 331.550000]: Robot started moving. Planning time: 0.0050 seconds
[INFO] [1743665313.674740, 331.552000]: Distance to goal: 3.6281 meters
[INFO] [1743665315.783949, 333.655000]: Goal sent at time: 1743665315.7834287
[INFO] [1743665315.788242, 333.660000]: Robot started moving. Planning time: 0.0044 seconds
[INFO] [1743665315.789963, 333.662000]: Distance to goal: 4.2195 meters
[INFO] [1743665317.300331, 335.169000]: Goal sent at time: 1743665317.3000097
[INFO] [1743665317.301080, 335.170000]: Robot started moving. Planning time: 0.0009 seconds
[INFO] [1743665317.304014, 335.173000]: Distance to goal: 3.8549 meters
[INFO] [1743665318.878592, 336.743000]: Goal sent at time: 1743665318.878343
[INFO] [1743665318.885201, 336.750000]: Robot started moving. Planning time: 0.0066 seconds
[INFO] [1743665318.887764, 336.752000]: Distance to goal: 4.9619 meters
[INFO] [1743665321.001717, 338.862000]: Goal sent at time: 1743665321.0014834
[INFO] [1743665321.009714, 338.870000]: Robot started moving. Planning time: 0.0080 seconds
[INFO] [1743665321.010766, 338.871000]: Distance to goal: 7.1233 meters
[INFO] [1743665322.819839, 340.676000]: Goal sent at time: 1743665322.8196862
[INFO] [1743665322.824158, 340.680000]: Robot started moving. Planning time: 0.0043 seconds
[INFO] [1743665322.826081, 340.682000]: Distance to goal: 4.5186 meters
[INFO] [1743665324.988213, 342.838000]: Goal sent at time: 1743665324.9877741
[INFO] [1743665324.989344, 342.840000]: Robot started moving. Planning time: 0.0013 seconds
[INFO] [1743665324.991962, 342.842000]: Distance to goal: 6.0952 meters
[INFO] [1743665327.489067, 345.334000]: Goal sent at time: 1743665327.4889095
[INFO] [1743665327.494855, 345.340000]: Robot started moving. Planning time: 0.0058 seconds
[INFO] [1743665327.497824, 345.342000]: Distance to goal: 3.5197 meters
[INFO] [1743665329.318154, 347.156000]: Goal sent at time: 1743665329.3176882
[INFO] [1743665329.319954, 347.160000]: Robot started moving. Planning time: 0.0020 seconds
[INFO] [1743665329.322820, 347.163000]: Distance to goal: 5.5632 meters
[INFO] [1743665331.675457, 349.509000]: Goal sent at time: 1743665331.6748805
[INFO] [1743665331.676185, 349.510000]: Robot started moving. Planning time: 0.0011 seconds
[INFO] [1743665331.678293, 349.513000]: Distance to goal: 4.7585 meters
[INFO] [1743665334.559273, 352.387000]: Goal sent at time: 1743665334.5591395
[INFO] [1743665334.562184, 352.390000]: Robot started moving. Planning time: 0.0028 seconds
[INFO] [1743665334.563312, 352.391000]: Distance to goal: 6.0067 meters
[INFO] [1743665336.821321, 354.644000]: Goal sent at time: 1743665336.8211
[INFO] [1743665336.827435, 354.650000]: Robot started moving. Planning time: 0.0060 seconds
[INFO] [1743665336.829070, 354.652000]: Distance to goal: 6.5093 meters
[INFO] [1743665338.776740, 356.594000]: Goal sent at time: 1743665338.7765846
[INFO] [1743665338.781795, 356.600000]: Robot started moving. Planning time: 0.0050 seconds
[INFO] [1743665338.783228, 356.601000]: Distance to goal: 5.5638 meters
[INFO] [1743665341.372018, 359.184000]: Goal sent at time: 1743665341.3718023
[INFO] [1743665341.377669, 359.190000]: Robot started moving. Planning time: 0.0056 seconds
[INFO] [1743665341.379261, 359.191000]: Distance to goal: 5.4733 meters
[INFO] [1743665345.675421, 363.477000]: Goal sent at time: 1743665345.6752162
[INFO] [1743665345.678213, 363.480000]: Robot started moving. Planning time: 0.0028 seconds
[INFO] [1743665345.679611, 363.481000]: Distance to goal: 5.4181 meters

"""

# 解析日志数据
goal_times = re.findall(r'Goal sent at time: ([\d.]+)', log_data)
planning_times = re.findall(r'Planning time: ([\d.]+) seconds', log_data)
distances = re.findall(r'Distance to goal: ([\d.]+) meters', log_data)

# 创建DataFrame
data = {
    'Goal Time': goal_times,
    'Planning Time (s)': planning_times,
    'Distance to Goal (m)': distances
}
df = pd.DataFrame(data)

# 将数据类型转换为浮点数
df['Goal Time'] = df['Goal Time'].astype(float)
df['Planning Time (s)'] = df['Planning Time (s)'].astype(float)
df['Distance to Goal (m)'] = df['Distance to Goal (m)'].astype(float)

# 绘制表格
fig, ax = plt.subplots()
ax.axis('tight')
ax.axis('off')
table = ax.table(cellText=df.values, colLabels=df.columns, cellLoc='center', loc='center')

plt.show()